from odoo import fields, models, api
from odoo.exceptions import UserError


class RPCourierToken(models.Model):
    _name = "rp.courier.token"
    _description = '承运商令牌'
    _rec_name = 'key'
    _sql_constraints = [('unique_name', 'UNIQUE(courier_id,key)', '名称必须唯一')]

    courier_id = fields.Many2one(string='承运商', comodel_name='rp.courier', ondelete='cascade')

    key = fields.Char(string='键', required=True, copy=False, index=True)

    value = fields.Char(string='值', required=True)
